package com.tjetc.utils;

import com.tjetc.entity.po.User;

/**
 * @author gaoyongxiang
 * @version v1.0
 * @since 2025-10-20
 */
public class UserContext {
    // InheritableThreadLocal(父子线程共享)
    // ThreadLocal 一个用户线程时共享数据
    private static  final ThreadLocal<User> USER_THREADLOCAL = new ThreadLocal<>();

    public static void saveUser(User user){
        USER_THREADLOCAL.set(user);
    }

    public static User getUser() {
        return USER_THREADLOCAL.get();
    }

    public static void removeUser() {
        USER_THREADLOCAL.remove();
    }

}
